package org.example;

import java.util.LinkedList;

// http协议工具类，主要是提供响应头信息，这里我们只提供200和404的情况
public class HttpProtocolUtil {

    //为响应码200提供请求头信息
    public static String getHttpHeader200() {
        LinkedList<String> list = new LinkedList<String>();
        list.add("HTTP/1.1 200 OK");
        list.add("Content-Type: text/html;charset=utf-8");
        list.add("\n");
        String join = String.join("\n", list);
        return join;
    }

    //为响应码404提供请求头信息(此处也包含了数据内容)
    public static String getHttpHeader404() {
        LinkedList<String> list = new LinkedList<String>();
        list.add("HTTP/1.1 NOT Found");
        list.add("Content-Type: text/html;charset=utf-8");
        list.add("\n");
        list.add("<h1>404 not found</h1>");
        String join = String.join("\n", list);
        return join;
    }

}
